<?php 
//给会员充值
if(!empty($_GET["act"]))
{
    $member_id=$_GET['member_id'];
    $sql="select status from ".TARENTO." where member_id='$member_id'";
    $db->query($sql);
    $v=$db->fetchRow();
    $action=($_GET['act']=='open')?'open':'close';
    unset($_GET['m']);
    unset($_GET['s']);
    unset($_GET['act']);
    unset($_GET['member_id']);
    if($v&&($v['status']==0)&&$action=='open')
    {
        $sql = "update ".TARENTO." set status=1 where member_id={$member_id}  limit 1";
        $db->query($sql);
        admin_msg('module.php?m=payment&s=payment_user.php&'.implode('&',convert($_GET)),'操作成功');
        
    }elseif($v&&$action=='close'){
        $sql = "update ".TARENTO." set status=0 where member_id={$member_id}  limit 1";
        $db->query($sql);
        admin_msg('module.php?m=payment&s=payment_user.php&'.implode('&',convert($_GET)),'操作成功');
        
    }
    
    admin_msg('module.php?m=payment&s=payment_user.php&'.implode('&',convert($_GET)),'操作失败，请检查数据');
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</HEAD>
<body>
<div class="bigbox">
  <div class="bigboxhead">账户列表</div>
  <div class="bigboxbody">
  
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <form name="frmuser" method="get">
      <input type="hidden" name="m" value="payment" />
      <input type="hidden" name="s" value="payment_user.php" />
        <tr>
          <td height="22"><?php echo lang_show('status');?></td>
          <td><select name="status">
              <option value="">全部</option>
              <option value="1" <?php if($_GET['status']==="1"){echo "selected";} ?>>开启</option>
              <option value="0" <?php if($_GET['status']==="0"){echo "selected";} ?>>冻结</option>
            </select>
          </td>
          <td height="22">余额</td>
          <td>
          <input class="rtext" name="cash_from" type="text" value="<?php echo $_GET['cash_from'];?>" size="40" />
            --
            <input class="rtext" name="cash_to" type="text" value="<?php echo $_GET['cash_to'];?>" size="40" /></td>
          <td height="22">会员ID</td>
          <td>
          <input class="rtext" name="userid" type="text" value="<?php echo $_GET['userid'];?>" size="40" />
          </td>
          <td height="22">手机</td>
          <td>
          <input class="rtext" name="mobile" type="text" value="<?php echo $_GET['mobile'];?>" size="40" />
          </td>
          <td><input class="btn" type="submit"   value="<?php echo lang_show('search');?>" /></td>
        </tr>
      </form>
    </table>
  
  
    <table width="100%" border="0" cellpadding="2" cellspacing="0" >
      <tr class="theader">
        <td width="5%" >会员ID</td>
        <td width="12%" >手机</td>
        <td>昵称</td>
        <td width="17%" align="left" >余额</td>
        <td width="17%" align="center" >查看明细</td>
        <td width="10%" colspan="2" >账户状态</td>
        <td width="14%" align="center" >充值</td>
      </tr>
    <?php
	$psql='';
	
	if($_GET['status']==='1'){
	    $psql.= " and b.status =1";
	}elseif ($_GET['status']==='0'){
	    $psql.=" and IFNULL(b.status,0)=0";
	}
	
	if ($_GET['cash_from']){
	    $psql.= " and b.account >={$_GET['cash_from']}";
	}
	if ($_GET['cash_to']){
	    $psql.= " and b.account <={$_GET['cash_to']}";
	}
	if ($_GET['userid']&&preg_match("/^[\d,]+$/", $_GET['userid'])){
	    $psql.= " and a.userid in({$_GET['userid']})";
	}
	if ($_GET['mobile']){
	    $psql.= " and a.mobile ={$_GET['mobile']}";
	}
	$sql="SELECT  a.userid,a.name,a.mobile,a.qq,a.weixin,b.account,b.status  FROM  ".MEMBER." as a left join ".TARENTO." as b on a.userid=b.member_id  WHERE 1 $psql ";
	//=============================
	include_once("../includes/page_utf_class.php");
	$page = new Page;
	$page->listRows=20;
	if (!$page->__get('totalRows')){
		$db->query($sql);
		$page->totalRows = $db->num_rows();
	}
	$sql .= "  limit ".$page->firstRow.",20";
	$pages = $page->prompt();
	//=============================
	$db->query($sql);
	$re=$db->getRows();
	unset($_GET['m']);
	unset($_GET['s']);
	
	foreach($re as $v)
	{ 
	?>
      <tr onMouseOver="mouseOver(this)" onMouseOut="mouseOut(this,'odd')">
        <td><?php echo $v["userid"]; ?></td>
        <td align="left"><?php echo $v['mobile'];?></td>
        <td align="left"><?php echo $v["name"]; ?></td>
        <td align="left"><?php echo floatval($v["account"]); ?></td>
        <td align="center"><a  href="module.php?m=payment&s=member_charge.php&member_id=<?php echo $v["userid"]; ?>">查看明细</a></td>
        <td align="left"><?php echo $v['status']?"<font color='green'>有效</font>":"<font color='red'>冻结</font>"; ?></td>
        <td align="left"><a  href="module.php?m=payment&s=payment_user.php&member_id=<?php echo $v["userid"];?>&act=<?php echo $v['status']?"close":"open"; ?>&<?php echo implode('&',convert($_GET)); ?>"><?php echo $v['status']?"冻结账户":"开启账户"; ?></a></td>
        <td align="center"><a  href="module.php?m=payment&s=member_charge.php&act=add&member_id=<?php echo $v["userid"]; ?>&<?php echo implode('&',convert($_GET)); ?>">充值</a></td>
        <?php 
    	}
		?>
      </tr>
      <tfoot>
            <tr>
                <td colspan="99">
                    <div class="page"><?php echo $pages?></div>
                共<?php echo $page->totalRows; ?>条
                </td>
            </tr>
        </tfoot>
    </table>
  </div>
</div>
</body>
</html>
